package lynch.net 
{
	import flash.system.ApplicationDomain;
	import flash.utils.describeType;
	/**
	 * every thing receive from Server
	 * @author 小痛
	 */
	public class Server 
	{
		private var enumObj:Object;
		
		public function Server() 
		{
			decodeAgreementEnum();
		}
		
		private function decodeAgreementEnum():void 
		{
			enumObj = {};
			var xml:XMLList = describeType(AgreementEnum).constant;
			for each (var item:XML in xml) 
			{
				var name:String = item.@name;
				enumObj[AgreementEnum[name]] = name;
			}
		}
		
		/**
		 * 消息分发
		 * @param	obj
		 */
		public function protocol(obj:Object):void
		{
			//read head, as usual it will be 4 bytes, なに(纳尼)? it is AMF = =!
			if (obj.head in enumObj)
			{
				this[enumObj[obj.head]].call(null, obj);
			}
		}
		
		//-------------------write all the handler here--------------
		
		private function S_CHECK_VERSION(obj:Object):void
		{
			
		}
	}

}